package wator.view.swing;

import wator.model.Integer2DVector;
import wator.model.Integer3DVector;
import wator.model.IntegerVector;
import wator.model.Simulation;

public class Grid {
	private IntegerVector size;
	private boolean visible;
	private boolean twoDimensional;
	private int x, y, z;
	
	public Grid() {
		x = y = z = 10;
		this.visible = false;
		this.twoDimensional = false;
		updateSizeVector();
	}
	
	public Grid(Integer3DVector size, boolean visible) {
		this.x = size.getX();
		this.x = size.getY();
		this.x = size.getZ();
		this.visible = visible;
		twoDimensional = (size.getZ() == 0); 
	}

	public IntegerVector getSize() {
		return size;
	}

	public void setSize(int x, int y, int z) {
		this.x = x;
		this.y = y;
		this.z = z;
		updateSizeVector();
	}
	
	public void updateSizeX (int x) {
		this.x = x;
		updateSizeVector();
	}
	
	public void updateSizeY (int y) {
		this.y = y;
		updateSizeVector();
	}
	
	public void updateSizeZ (int z) {
		this.z = z;
		updateSizeVector();
	}

	public boolean isVisible() {
		return visible;
	}

	public void setVisible(boolean visible) {
		this.visible = visible;
	}

	public boolean isTwoDimensional() {
		return twoDimensional;
	}

	public void setTwoDimensional(boolean twoDimensional) {
		this.twoDimensional = twoDimensional;
		updateSizeVector();
	}
	
	private void updateSizeVector() {
		size = twoDimensional ? new Integer2DVector(x, y)
			: new Integer3DVector(x, y, z);;
		Simulation.getInstance().setSizeVector(size);
	}
}
